<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>View Courses</title>
</head>

<body>
	<?php
        //if (isset($_COOKIE["Studial"]))
        //{
			//$nameCookie = $_COOKIE['Studial'];
			
			$UniversityID = $_GET['UniversityID'];
			$FacultyID = $_GET['FacultyID'];
			$SubjectID = $_GET['SubjectID'];
			$courseName = $_GET['courseName'];
			$courseDescription = $_GET['courseDescription'];
			$startDate = getdate();
			$periodTime = $_GET['UniversityID'];
			
            $ini_array = parse_ini_file("../config1.ini");
			@ $con = mysql_pconnect($ini_array['dblink'], $ini_array['dbuser'], $ini_array['dbpass']);
					
			$nameCookie = $_COOKIE['Studial'];
				
			if (!$con)
			{
				die('Could not connect: ' . mysql_error());
			}
				
			@ mysql_set_charset('utf8');
			@ mysql_select_db($ini_array['dbname']);
			
			$query = "INSERT INTO `Studial`.`courses` (`university_id`, `faculty_id`, `subject_id`, `name`, `description`, `startdate`, `period`) VALUES ('".$UniversityID."', '".$FacultyID."', '".$SubjectID."', '".$courseName."', '".$courseDescription."', '".$startDate."', '".$periodTime."')";
			$officalmovies = mysql_query($query);
				
			if ( $officalmovies != false && $tempmovies != false )
			{
                echo "<h1 align='center' style='color:#00CC00'>Course ".$courseName." have been added into database!</h1>";
			}
			else
			{
				echo "<h1 align='center' style='color:#00CC00'>Course ".$courseName." have NOT been added into database!</h1>";
			}
        //}
        //else
        //{
            //header('location: ../login/deletecookies.php');
            //exit;
        //}
	?>
    
    	<h2 align="center">Danh sách các khóa học</h2>
        <table border="1" align="center">
            <tr align="center">
            	<td>UniversityID</td>
                <td>FacultyID</td>
                <td>SubjectID</td>
                <td>Course Name</td>
                <td>Description</td>
                <td>Start Date</td>
                <td>Period Time</td>
            </tr>
            <?php
				//$nameCookie = $_COOKIE['Studial'];
                
                mysql_set_charset('utf8');
                
                mysql_select_db($ini_array['dbname']);
				
                $select = "SELECT * FROM `courses`";
                $result = mysql_query($select);
				
                $numresult = mysql_num_rows($result);
				
                for($i=1; $i<=$numresult; $i++)
                {
                    $row = mysql_fetch_array($result);
					echo "<tr><td>".stripslashes($row['university_id'])."</td>";
                    echo "<td>".stripslashes($row['faculty_id'])."</td>";
					echo "<td>".stripslashes($row['subject_id'])."</td>";
					echo "<td>".stripslashes($row['name'])."</td>";
					echo "<td>".stripslashes($row['description'])."</td>";
					echo "<td>".stripslashes($row['startdate'])."</td>";
					echo "<td>".stripslashes($row['period'])."</td></tr>";
                }
            ?>
        </table>
</body>
</html>